package first.niuke.midding;

/**
 * @ClassName NC104
 * @description:
 * @author: 荣燊
 * @create: 2021-06-13 14:59
 **/
public class NC104 {
    public static void main(String[] args) {
//        String s = "1.11.02.02.45";
//        String[] s1 = s.split("\\.");
//        for (String a : s1) {
//            System.out.println(a);
//        }
    }

    public int compare (String version1, String version2) {
        // write code here
        String[] ver1 = version1.split("\\.");
        String[] ver2 = version2.split("\\.");
        int i = 0;
        for (; i<Math.min(ver1.length, ver2.length); i++) {
            if (Integer.parseInt(ver1[i]) == Integer.parseInt(ver2[i])) {
                continue;
            }
            return Integer.parseInt(ver1[i]) > Integer.parseInt(ver2[i]) ? 1 : -1;
        }

        while (i < ver1.length) {
            if (Integer.parseInt(ver1[i]) > 0) {
                return 1;
            }
            i++;
        }

        while (i < ver2.length) {
            if (Integer.parseInt(ver2[i]) > 0) {
                return -1;
            }
            i++;
        }
        return 0;
    }
}
